package in.muton.edushare.poll.sections;

import in.muton.edushare.pages.EduShareBasePage;
import in.muton.edushare.pages.common.EdusharePanel;
import in.muton.edushare.poll.panels.SummaryPanel;

import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.IModel;

import com.edushare.common.vo.Poll;

public class PollResultsPanel extends EdusharePanel {
	private static final long serialVersionUID = 6840552327739460567L;
	private IModel<Poll> pollModel;
	private PollSectionResult p;

	public PollResultsPanel(String id, IModel<Poll> model, EduShareBasePage page) {
		super(id, page);
		pollModel = model;
		
		add(new SummaryPanel("summaryPanel", pollModel, page));
		add(p = new PollSectionResult("activePage", PollSection.getPageByNum(
				pollModel, 1), page));
		Form<Void> f = new Form<Void>("navigation");
		
		f.add(new Button("prev") {
			@Override
			public void onSubmit(){
				 p.prevPage();
			}
			@Override
			public boolean isVisible(){
				return p.isPrevPagePresent();
			}
			private static final long serialVersionUID = -1888613419450104226L;
		});
		
		f.add(new Button("next") {
			@Override
			public void onSubmit(){
				p.nextPage();
			}
			@Override
			public boolean isVisible(){
				return p.isNextPagePresent();
			}
			
			private static final long serialVersionUID = 7613286693211994612L;
		});
		add(f);
	}
}
